package com.rpj.dao;

import java.util.List;

import javax.transaction.Transactional;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import com.rpj.entity.StuEntity;

public interface StuDao extends JpaRepository<StuEntity, String>,JpaSpecificationExecutor<StuEntity>{
	
//��ѯȫ��
@Query(value="select students.* from students order by stuid asc",nativeQuery = true)
List<StuEntity> queryall();
//�޸�
@Modifying 
@Transactional 
@Query(value =
"update students as s set s.stuname=?1 ,s.stupassword=?2, s.sex=?3,"
+ "s.status=?4,s.department=?5,s.specialty=?6,s.degree=?7,"
+ "s.stuborrowbooknum=?8,s.stuborrowmaxnum=?9,s.stugivebooknum=?10,s.data1=?11,s.data2=?12,s.data3=?13 where stuid=?14" + 
		" ",nativeQuery = true)
int updateStu(String stuname,String stupassword,String sex,String status,
		String department,String specialty,String degree,String stuborrowbooknum,String stuborrowmaxnum,String stugivebooknum,String data1,String data2,String data3,String id);


//查询专业
@Query(value ="select s.specialty from students as s GROUP BY specialty",nativeQuery = true)
List<String>  selMajor();
//用户名，密码，登陆
@Query(value="select * from students where stuname=?1 and stupassword=?2",nativeQuery=true)
StuEntity stulogin(String stuname,String stupassword);
	
}
